<template>
  <div class="filterbar-container">
    <div class="filterbar-header">
      <nav>
        <span v-if="showBack" @click="goRoute"><svg-icon icon-class="back" />返回</span>
        <slot name="left" />
      </nav>
      <section>
        <slot name="right" />
      </section>
    </div>
  </div>
</template>

<script>
import { defineComponent } from "vue";

export default defineComponent({
  name: "FilterBar",
  emits: ["route"],
  props: {
    showBack: {
      type: Boolean,
      default: false
    }
  },
  setup(props, { emit }) {
    const goRoute = () => {
      emit('route')
    }
    return {
      goRoute
    }
  }
});
</script>

<style lang="scss" scoped>
@import "@/styles/variables.module.scss";
h4 {
  margin: 0;
  // margin-bottom: 16px;
  height: 36px;
  line-height: 36px;
  color: #3C475D;
  font-size: 18px;
  font-weight: 600;
  cursor: default;
  :deep(a) {
    cursor: pointer;
    color: $mainColor;
  }
}
.filterbar-header {
  display: flex;
  
  // padding-bottom: 16px;
  nav {
    flex: 1;
    text-align: left;
    span {
      display: inline-block;
      margin-right: 20px;
      color: #2E69EB;
      font-size: 16px;
      border-right: 1px solid #ddd;
      padding-right: 20px;
      cursor: pointer;
    }
    h4 {
      border-top-left-radius: 4px;
      border-top-right-radius: 4px;
      background: #fff;
      display: inline-block;
      padding: 0 20px;
      height: 45px;
      line-height: 45px;
    }
  }
  section {
    text-align: right;
  }
}
.icon {
  cursor: pointer;
  vertical-align: -2px;
  margin-left: 1px;
}
</style>